//@author A0088498A
package common;

/**
 * The warper for Command <br/>
 * Command is used to communicate between Controller/Logic and Model/Storage <br/>
 * Contains 3 main fields: <br/>
 * - Raw command string from users <br/>
 * - Type of the command <br/>
 * - The parsed Task <br/>
 */

public class Command {
	protected String _commandString; // the raw command string user has typed.
										// This is used to recall commands
	protected CommandType _type;
	protected Task _task; // the parsed Task from the command arguments

	/**
	 * Constructor <br/>
	 * 
	 * @param command
	 *            String that the users have typed in
	 * @param type
	 *            the type of the Task
	 * @param task
	 *            the task object
	 */
	public Command(String commandString, CommandType type, Task task) {
		_commandString = commandString;
		_type = type;
		_task = task;
	}

	/**
	 * Get command string
	 * 
	 * @return the command string user has typed
	 */
	public String getCommandString() {
		return _commandString;
	}

	/**
	 * Return the type of the command
	 * 
	 * @return the command type
	 */
	public CommandType getType() {
		return _type;
	}

	/**
	 * Return the Task object parsed
	 * 
	 * @return the Task object
	 */
	public Task getTask() {
		return _task;
	}

	/**
	 * Determine if this is an executable command
	 * 
	 * @return true if this is an executable command, otherwise false
	 */
	public boolean isExecutable() {
		boolean isExecutable;
		CommandType type = this.getType();

		switch (type) {
		case add:
		case delete:
		case update:
		case undo:
		case confirm:
		case mark:
		case unmark:
		case discard:
		case block:
		case unblock:
			isExecutable = true;
			break;
		default:
			isExecutable = false;
			break;
		}

		return isExecutable;
	}
}
